// 下载 mysql 模块 | npm i mysql 

//导入模块
const mysql = require('mysql');

//创建数据库连接对象

const db = mysql.createConnection({
    host: "127.0.0.1",
    user: "root",
    password: 'root',
    database: 'baiduapi'
})

// 向外共享db数据库连接对象
db.connect(error => {
    if (error) throw error;
    console.log("Successfully connected to the database.");
});
setInterval(function () {
    db.query('SELECT 1');
    console.log("数据库准备完成")
}, 5000);
module.exports = db;